// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Blaster/PlayerController/BlasterPlayerController.h"
#include "GameFramework/GameMode.h"
#include "BlasterGameMode.generated.h"

class ABlasterCharacter;
class ABlasterPlayerController;
class ACharacter;
class AController;

namespace MatchState
{
	extern BLASTER_API const FName Cooldown; //比赛结束冷却时间
}

//EnteringMap：游戏正在进入地图，Actors还不能行动
//WaitingToStart：Actors可以行动，但是匹配还没有开始
//InProgress：正常游戏正在进行中，特定游戏将在此状态下拥有自己的状态机
//WaitingPostMatch：匹配已经结束不会接受新玩家，但Actors仍可以行动
//LeavingMap：游戏将离开地图转移到另个位置
//Aborted：匹配失败取决于网络错误或其他原因，不能继续
/**
 * 
 */
UCLASS()
class BLASTER_API ABlasterGameMode : public AGameMode
{
	GENERATED_BODY()
public:
	ABlasterGameMode();
	virtual void Tick(float DeltaTime) override;
	//Eliminate：淘汰
	//Victim：受害者
	virtual void PlayerEliminated(ABlasterCharacter* EliminatedCharacter, ABlasterPlayerController* VictimController,
	                              ABlasterPlayerController* AttackerController);
	virtual void RequestRespawn(ACharacter* ElimmedCharacter, AController* ElimmedController);
	void PlayerLeftGame(class ABlasterPlayerState* PlayerLeaving);

	virtual float CalculateDamage(AController* Attacker, AController* Victim, float BaseDamage);

	UPROPERTY(EditDefaultsOnly)
	float WarmupTime{10.f}; //热身时间
	UPROPERTY(EditDefaultsOnly)
	float MatchTime{120.f}; //比赛时间
	UPROPERTY(EditDefaultsOnly)
	float CooldownTime{10.f}; //冷却时间
	float LevelStartingTime{0.f}; //关卡开启所花时间

	bool bTeamsMatch{false};
protected:
	virtual void BeginPlay() override;
	virtual void OnMatchStateSet() override; //监听匹配状态变化时调用
private:
	float CountdownTime{0.f};
public:
	FORCEINLINE float GetCountdownTime() const { return CountdownTime; }
};
